﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace QLNS
{
    public partial class frmTimkiem : Form
    {
        public frmTimkiem()
        {
            InitializeComponent();
        }
        public SqlConnection getConnect()
        {
            return new SqlConnection(@"Data Source=THANGVUONG\SQLEXPRESS;Initial Catalog=Quanlynhansu;Integrated Security=True");
        }
        public DataTable Nhanvien_SearchALL(Nhanvien nv)
        {
            SqlConnection conn = getConnect();
            conn.Open();
            SqlCommand cmd = new SqlCommand("Nhanvien_SearchAll", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@id", nv.MaNV));
            SqlDataAdapter adap = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            adap.Fill(dt);
            conn.Close();
            return dt;
        }
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            Nhanvien NV = new Nhanvien();
            NV.MaNV = txtSearch.Text;
            grvNhanvien.DataSource = Nhanvien_SearchALL(NV);
        }
    }
}
